<?php
/**
 * Created by lzl
 * Date: 2021 2021/9/23
 * Time: 12:53
 */
namespace App\Http\Controllers\Admin;

use App\Forms\ConfigForms;

class ConfigController extends Controller
{
    /**
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|mixed
     * @throws \App\Exceptions\RequestException
     */
    public function index()
    {
        $forms = new ConfigForms();

        if($this->request->ajax()) {
            $rules = [
                'array' => 'required|array',
            ];

            $this->validateInput($rules);

            return $this->success($forms->updateConfig($this->validated['array']));
        }

        return $this->view('config.index', ['list' => $forms->getConfig()]);
    }
}